﻿<Window 
    xmlns:local="clr-namespace:DataBinding"
    x:Class="DataContextSetFromAnotherControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="DataContext Set From Another Control" Height="294" Width="504">

    <Grid>
        <!-- run, appears to not reflect changes, then bring in the template from file 06.  Why is this?-->
        <GroupBox Header="Select Customer" Margin="20,24,0,60" HorizontalAlignment="Left" Width="175" Padding="7">
            <ListBox ItemsSource="{x:Static local:Data.People}" Name="lbCustomers"/>
        </GroupBox>
        <GroupBox Header="Customer Details" HorizontalAlignment="Right" Margin="0,24,34,60" Width="175">
            <StackPanel DataContext="{Binding ElementName=lbCustomers, Path=SelectedItem, Mode=TwoWay}">
                <Label Foreground="DarkGray">First Name</Label>
                <TextBox Text="{Binding Path=FirstName}" Margin="20,-5,11,7" />
                <Label Foreground="DarkGray">Last Name</Label>
                <TextBox Text="{Binding Path=LastName}" Margin="20,-5,11,7" />
                <Label Foreground="DarkGray">Birthday</Label>
                <TextBox Text="{Binding Path=Birthday, TargetNullValue='', StringFormat=d}" Margin="20,-5,11,7" />
            </StackPanel>
        </GroupBox>
    </Grid>
</Window>
